<?php
/*=============================================================================
|| ##################################################################
||	phpFoX Konsort
|| ##################################################################
||
||	Copyright		: (C) 2005-2007 PHPFOX Limited a Reality Fox Creation
||	Contact			: info@phpfox.com
||
||	- phpFoX and all of its source code and files are protected by Copyright Laws.
||
||	- The license for phpFoX permits you to install this software on a single domain (.com, .org, .net, etc.).
||
||	- You may also not remove this copyright screen which shows the copyright information and credits for phpFoX (RealityFOX Creations).
||
||	- phpFoX Konsort is NOT a FREE software - http://www.phpfox.com/license/
||
|| ##################################################################
=============================================================================*/

/* $File: ./include/classes/smarty/plugins/function.url.php, $Author:  $ */

function smarty_function_url($params, &$smarty)
{

    //get link parameter
    if(!isset($params['link']))
    {
        return '/errors/bad_url_nolink.html';
	}
    $sLink = $params['link'];
    $bVerifyUrl = (isset($params['bVerifyUrl']) ? $params['bVerifyUrl'] : false);
    unset($params['link']);
    unset($params['bVerifyUrl']);

         if(isset($params['foxseotitle']))
         {
         	$oBan = &App::getModuleService('Site', 'Ban');
         	$chars = 50;
            $params['title'] = App::formatTranslate($params['foxseotitle']);
            $params['title'] = $oBan->parseStringForBadwords($params['title']);
            $params['title'] = $params['title']." ";
            $params['title'] = substr($params['title'],0,$chars);
            $params['title'] = substr($params['title'],0,strrpos($params['title'],' '));
            $params['title'] = $params['title']."";
            $params['title'] = App::cleanUrl($params['title']);
        }
        unset($params['foxseotitle']);

    //get URL
    if ($sLink != 'current')
    {    	
    	$sUrl = (isset($bVerifyUrl) ? (substr($sLink, 0, 7) == 'http://' ? $sLink : App::makeUrl($sLink, $params)) : App::makeUrl($sLink, $params));
    }
    else
    {
		$oUrl = &App::getUrl();
        $oUrl->setParams($params);
        $sUrl = $oUrl->getUrl();
		$sUrl = App::replaceUrls($sUrl, true);
    }
    $sUrl = str_replace(' ', '%20', $sUrl);
    if (!$sUrl)
    	return '/errors/bad_url.html';
    return $sUrl;
}
?>